/*******************************************************************************
 * Copyright (c) 2010, 2030 www.mahao.cn
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package cn.itlaobing.ssh.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import cn.itlaobing.ssh.entity.Users;
import cn.itlaobing.ssh.service.UsersService;

/** 
 * ClassName: SessionController <br/> 
 * Function: TODO 功能描述 <br/> 
 * date: 2017年6月29日 下午3:49:00 <br/> 
 * 
 * @author Mmmmm 
 * @version  
 * @since JDK 1.8 
 */
@Controller
public class SessionController {
	@Autowired
	private UsersService usersService;

	@RequestMapping(value={"/signin"},method=RequestMethod.GET)
	public String login(){
		return "login";
	}
	
	@PostMapping("/signin")
	public String signin(String name,String password){
		Users user = usersService.findByUser(name, password);
		if(null != user){
			return "index";
		}else{
			return "redirect:/signin";
		}
	}
}
